#pragma once
#include "PAKWriter.h"
#include "DeclarationManager.h"

namespace ds {

class ScreenQuadDecl : public ResourceDeclaration {

struct QuadDecl {
	Vec2 pos;
	Vec2 size;
	Rect rect;
};

typedef std::vector<QuadDecl> Quads;

public:
	ScreenQuadDecl(const std::string& nodeName,const std::string& material,const std::string& layer,int vertices) 
		: ResourceDeclaration(nodeName) , m_NodeName(nodeName) , m_Material(material) , m_Layer(layer) , m_Vertices(vertices) {}	
	virtual ~ScreenQuadDecl() {}
	void parseCategory(Category* category) {}
	DeclarationType getType() const {
		return DT_SCREEN_QUAD;
	}		
	void createResource();
	void addQuad(const Vec2& pos,const Vec2& size,const Rect& textureRect) {
		QuadDecl q;
		q.pos = pos;
		q.size = size;
		q.rect = textureRect;
		m_Quads.push_back(q);
	}
private:
	std::string m_NodeName;
	std::string m_Material;
	std::string m_Layer;
	int m_Vertices;
	Quads m_Quads;
};

class ScreenQuadParser : public DeclarationParser {

public:
	ScreenQuadParser() : DeclarationParser() {}
	virtual ~ScreenQuadParser() {}
	ResourceDeclaration* loadTextFile(const ResourceFile& resourceFile);
	void loadTextFile(const ResourceFile& resourceFile,DeclarationManager* declarationManager) {}
	void createResource(ResourceDeclaration* declaration);
	DeclarationType getType() const {
		return DT_SCREEN_QUAD;
	}
	bool isSupported(const std::string& fileEnding) const {
		return fileEnding == ".squad";
	}
	bool isReloadable() const {
		return true;
	}	
};

}

